import DelButton from '../../../components/delbutton';
import { IData } from '../../api/professional/course/query.api';
import Edit from './edit';
import api from '../../../atoms/api';
import Table from '../../../components/table';

export default function List({ data, majors, groups }: {
	data: IData[];
	majors: Pick<ITbmajor, 'majorname' | 'major_id'>[];
	groups: Pick<ITbgroup, 'group_id' | 'groupname'>[];
}) {
	return <>
		<Table
			idfieldname='group_id'
			render={(record) => {
				const { groupname, majorname, ...data } = record;
				const id = record.curriculum_id;
				return <>
					<Edit majors={majors} groups={groups} data={data} />
					<DelButton query={{
						id
					}} dlgtitle='确认删除' api={api['/api/professional/course/del']} />
				</>;
			}}
			data={data}
		>
			<Table.Column<IData> title='课组名称' key='groupname' dataIndex='groupname' align='left' />
			<Table.Column<IData> title='课程名称' key='coursename' dataIndex='coursename' align='left' />
			<Table.Column<IData> title='课程类型' key='type' dataIndex='type' align='left' />
			<Table.Column<IData> title='课程学分' key='credit' dataIndex='credit' align='left' />
			<Table.Column<IData> title='授课学期' key='semester' dataIndex='semester' align='left' />
			<Table.Column<IData> title='课程简介' key='courseintroduction' dataIndex='courseintroduction' align='left' />
		</Table>
	</>;
}
